<?php if (!empty($model)) :?>
<div class="related products">
	<h2>Related Products</h2>
	<ul class="products">
	<?php
		$count = 0;

		foreach ($model as $key=>$value):

			$item = $value->products;
			
			if (!empty($item)):
					if ((($key+1) % 3) == 0) {
						$count = 0;
						$cls = "last";
					} else {
						if ($count == 0) {
							$cls = "first";
						} else {
							$cls ="";
						}
					}
					$count ++;
					

					
					$path = Yii::app()->baseUrl."/upload_files/products";

					$folder_dir = Yii::getPathOfAlias('webroot')."/wwwroot/{$path}/{$item->image}";

					if (!is_file($folder_dir)) {
						$src = Yii::app()->baseUrl."/uploads/no-image.png";
					} else {
						$src = Yii::app()->baseUrl."/wwwroot/{$path}/{$item->image}";
					}
					
		?>
				<li class="product <?php echo $cls;?>">
					<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $item->alias))?>">
						<span class="onsale">Sale!</span>	
						<img src="<?php echo $src;?>" class="attachment-shop_catalog wp-post-image" alt="<?php echo $item->name?>" />
						<h3><?php echo $item->name?></h3>
						<span class="price"><span class="from">From: </span><span class="amount">&#36;25</span></span>
					</a>
					<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $item->alias))?>" data-product_id="208" class="button add_to_cart_button product_type_variable">Select options</a>			
				</li>
			<?php endif;?>
		<?php endforeach;?>
	</ul>
	<div class="clear"></div>
</div>
<?php endif;?>